#Update Metz dataset in order to
#- binarize interactions
#- transform to be loadable into HLM
dSimMat <- read.table("drug-drug_similarities_2D__Metz_et_al.2011.txt", header = FALSE, sep=" ")
tSimMat <- read.table("target-target_similarities_WS_normalized__Metz_et_al.2011.txt", header = FALSE, sep=" ")
intMat  <- read.table("known_drug-target_interaction_affinities_pKi__Metz_et_al.2011.txt", header = FALSE, sep=" ")

tSimMat <- tSimMat / 100
dSimMat <- dSimMat / 100

for (i in c(1:length(intMat[,1]))){
  intMat[i,which(intMat[i,] > 0)] <- 1
}
intMat[is.na(intMat)] <- 0

im = data.matrix(intMat)
table(im)

write.table(dSimMat, file = "metz_simmat_dg.txt",row.names=TRUE, na="",col.names=TRUE, sep=" ")
write.table(tSimMat, file = "metz_simmat_dc.txt",row.names=TRUE, na="",col.names=TRUE, sep=" ")
write.table(intMat, file = "metz_simmat_dcg.txt",row.names=TRUE, na="",col.names=TRUE, sep=" ")



#Update Davis dataset in order to
#- binarize interactions
#- transform to be loadable into HLM
dSimMat <- read.table("drug-drug_similarities_2D.txt", header = FALSE, sep=" ")
tSimMat <- read.table("target-target_similarities_WS_normalized.txt", header = FALSE, sep=" ")
intMat  <- read.table("drug-target_interaction_affinities_Kd__Davis_et_al.2011.txt", header = FALSE, sep=" ")

tSimMat <- tSimMat / 100
#dSimMat <- dSimMat / 100

for (i in c(1:length(intMat[,1]))){
  intMat[i,which(intMat[i,] <= 30)] <- 1
  intMat[i,which(intMat[i,] != 1)] <- 0
}


im = data.matrix(intMat)
table(im)

write.table(dSimMat, file = "davis_simmat_dg.txt",row.names=TRUE, na="",col.names=TRUE, sep=" ")
write.table(tSimMat, file = "davis_simmat_dc.txt",row.names=TRUE, na="",col.names=TRUE, sep=" ")
write.table(intMat, file = "davis_admat_dgc.txt",row.names=TRUE, na="",col.names=TRUE, sep=" ")
